﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;

namespace Kimd.Motion
{
    public class Pdo
    {
        public short PortNo { get; set; }
        public short Address { get; set; }
        public string Description { get; set; }
        public string ControlCardName { get; set; }
        public string Module { get; set; }
        private ControlCard _card;
        [XmlIgnore]
        public ControlCard Card
        {
            set { _card = value; }
            get { return _card; }
        }
        public Pdo()
        {

        }
        public Pdo(string cardName, short portNo, short address, string description, string moduleName)
            : this()
        {
            this.ControlCardName = cardName;
            this.PortNo = portNo;
            this.Address = address;
            this.Description = description;
            this.Module = moduleName;
        }
        public void SetData(int value)
        {
            _card.PdoOperator.WritePdoData((ushort)_card.CardNo, (ushort)PortNo, (ushort)Address, 2, value);
        }
        public int ReadData()
        {
            int val = 0;
            _card.PdoOperator.ReadPdoData((ushort)_card.CardNo, (ushort)PortNo, (ushort)Address, 2, ref val);
            return val;
        }
    }
}
